package com.feng.common.model;


import com.feng.common.utils.AssertUtils;

public interface Pageable {

    /**
     * 页码
     */
    int getPage();

    /**
     * 每页大小
     */
    int getSize();

    /**
     * Offset
     */
    long getOffset();

    static Pageable of(int page, int size) {
        return new PageRequest(page, size);
    }

    static Pageable from(Pageable pageable) {
        AssertUtils.isNotNull(pageable, "pageable must not be null!");
        return new PageRequest(pageable.getPage(), pageable.getSize());
    }
}
